package com.evil.application.pojo.dto.queue;

import com.evil.application.pojo.entity.ApplicationQueue;
import com.evil.common.application.enums.queue.QueueStatusEnum;
import com.evil.common.application.enums.queue.QueueTypeEnum;
import com.evil.common.core.enums.SwitchEnum;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 队列 请求实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class AddQueueReqDTO {

    /**
     * 企业id
     */
    private Long enterpriseId;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 队列标题
     */
    @NotBlank(message = "队列标题不能为空")
    private String queueTitle;

    /**
     * 队列类型（1-订单导入，2-订单导出，3-套打模板）
     */
    @NotNull(message = "队列类型不能为空")
    private Integer queueType;

    /**
     * 队列文件
     */
    private Long queueFileId;

    /**
     * 队列内容
     */
    private String queueContent;

    /**
     * 备注
     */
    private String remark;

    public void check() {
        QueueTypeEnum.isExistById(queueType);
    }

    public ApplicationQueue createApplicationQueue() {
        ApplicationQueue applicationQueue = new ApplicationQueue();
        applicationQueue.setEnterpriseId(this.enterpriseId);
        applicationQueue.setUserId(this.userId);
        applicationQueue.setQueueTitle(this.queueTitle);
        applicationQueue.setQueueType(this.queueType);
        applicationQueue.setQueueStatus(QueueStatusEnum.PREPARING.getId());
        applicationQueue.setQueueFileId(this.queueFileId);
        applicationQueue.setQueueContent(this.queueContent);
        applicationQueue.setReadStatus(SwitchEnum.NO.getId());
        applicationQueue.setRemark(this.remark);
        return applicationQueue;
    }
}
